package com.txunda.zhuohired.adapter.user.my;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.bean.user.my.BankTypeBean;

import java.util.List;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/8 15:05
 * 功能描述：银行卡类型adapter
 * 联系方式：jiahuanchen@126.com
 */

public class BankTypeAdapter extends BaseAdapter {
    private Context context;
    private List<BankTypeBean.DataBean> bankNameList;
    private ViewHolder holder;

    public BankTypeAdapter(Context context, List<BankTypeBean.DataBean> bankNameList) {
        this.context = context;
        this.bankNameList = bankNameList;
    }

    @Override
    public int getCount() {
        return bankNameList.size();
    }

    @Override
    public Object getItem(int i) {
        return bankNameList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_bank_type, null);
            holder = new ViewHolder();
            view.setTag(holder);
            ViewUtils.inject(holder, view);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tv_item_bank_type.setText(bankNameList.get(i).getBank_name());
        Glide.with(context).load(bankNameList.get(i).getBank_icon()).error(R.mipmap.icon_defult).placeholder(R.mipmap
                .icon_defult).dontAnimate().into(holder.iv_item_bank_type);
        return view;
    }

    class ViewHolder {
        /**
         * 银行名称
         */
        @ViewInject(R.id.tv_item_bank_type)
        private TextView tv_item_bank_type;
        /**
         * 银行卡图片
         */
        @ViewInject(R.id.iv_item_bank_type)
        private ImageView iv_item_bank_type;
    }
}
